<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<html>
	<head>
		<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
		<title>作废重开-金融风险管理系统</title>
		<script src="${contextPath}/scripts/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
		<script src="${contextPath}/scripts/common.js" type="text/javascript"></script>
		<script src="${contextPath}/scripts/scriptvalidator.js" type="text/javascript"></script>
		<script src="${contextPath}/scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
		<link href="${contextPath}/styles/default.css" rel="stylesheet" type="text/css" />
		<script language='javascript'>
		String.prototype.replaceAll =function(s1,s2) {

		    return this.replace(new RegExp(s1,"gm"),s2);

		};
		
		function jumpPage(page) {
			var form1 = document.form1;
			form1.action = "<s:property value='contextPath'/>/cs/add.do?currentPage=" + page;
			form1.submit();
		}
		  
	  $(document).ready(function(){            
			$("#check_all").click(function(){  
				$('[type=checkbox][disabled!=disabled]').attr('checked', $("#check_all").is(':checked'));
			});
			
			$("[type=button][name='btn_submit']").click(function(e){
				var check = $("input[name='mid']:checked"); //得到所有被选中的checkbox
				var re_check=$("[type=checkbox][name='mid'][disabled!=disabled][checked=checked]");//非实收被选中的
				var un_check=$("[type=checkbox][name='mid'][disabled!=disabled][checked!=checked]");//没被选中的
				if(re_check.length==0){
					alert("请至少选择一条需要重开的费用明细");
				}else{
					if(check.length!=re_check.length)
						$("#hasCharged").val("true");
					var ids='';              //定义变量
				   check.each(function(i){         //循环拼装被选中项的值
					   if(i!=check.length-1){
						   ids+=$(this).attr('id')+',';
					   }else{
						   ids+=$(this).attr('id');
					   }
				    });
				   $("#ids").val(ids);
					var uncheckIds='';              //定义变量
					un_check.each(function(j){         //循环拼装被选中项的值
					   if(j!=un_check.length-1){
						   uncheckIds+=$(this).attr('id')+',';
					   }else{
						   uncheckIds+=$(this).attr('id');
					   }
				    });
				   $("#uncheckIds").val(uncheckIds);
				   
				  $("#form1").submit();
				}
				   
			});
			
			});

		</script>
	</head>
	<body  leftmargin='8' topmargin='8'>
	<div class="navigation">
	    <span><a href="javascript:window.history.back();"><img src="${contextPath}/images/back_nav_btn.png" /></a>
	    <a href="javascript:window.history.back();">返回</a>
	    <a href="javascript:window.history.forward();"><img src="${contextPath}/images/go_nav_btn.png" /></a>
	     <a href="javascript:window.history.forward();">前进</a>
	    <a href="javascript:window.location.reload();"><img src="${contextPath}/images/refresh_nav_btn.png" /></a>
	     <a href="javascript:window.location.reload();">刷新</a>
 	    </span>管理费&gt;&gt;发票管理&gt;&gt;作废重开
    
  	</div>
		<div class="xt_main_right_center">
		<form id="form1" name="form1" action="reopen.do" method="post"  onSubmit="return Validator.Validate(this,3)">
			<table width="100%" border="0" cellpadding="1" cellspacing="1">
			<tr>
				<td class="left-td-width-bg">
					发票号：
				</td>
				<td width="30%" class="bline" align="left">
					<s:property value="bill.billNum"/>
				</td>
				<td class="left-td-width-bg">
					发票名：
				</td>
				<td width="25%" class="bline" align="left">
					<s:property value="bill.billName"/>
				</td>
				<td class="left-td-width-bg">
					发票金额：
				</td>
				<td width="25%" class="bline" align="left">
					<s:property value="formatAmount(bill.receivableAmount)"/>
				</td>
			</tr>
			<tr>
				<td class="left-td-width-bg">
					<s:if test="bill.shop==null">
						金融机构：
					</s:if>
					<s:else>店名:</s:else>
				</td>
				<td width="30%" class="bline" align="left">
					<s:if test="bill.shop==null">
						<s:property value="bill.financial.name"/>
					</s:if>
					<s:else><s:property value="bill.shop.shopName"/></s:else>
					
				</td>
				<td class="left-td-width-bg">
					申请时间：
				</td>
				<td width="30%" class="bline" align="left" >
					<s:property value="bill.applyDate"/>
				</td>
				<td class="left-td-width-bg">
					开票日期：
				</td>
				<td width="25%" class="bline" align="left">
					<s:date name="bill.openDate" format="yyyy-MM-dd"/>
				</td>
			</tr>
			<tr>
				<td class="left-td-width-bg">
					新发票发票号：
				</td>
				<td width="25%" class="bline" align="left">
					<input name="billNum"  type="text" dataType="Require" msg="发票号不能为空"  />
				</td>
				<td class="left-td-width-bg">
					新发票发票名：
				</td>
				<td width="25%" class="bline" align="left">
					<input name="billName"  type="text" dataType="Require" msg="发票名不能为空" />
				</td>
				<td class="left-td-width-bg">新发票开票时间：</td>
		        <td>
				  	<input  dataType="Require" msg="请选择开票时间"  name="openDate"   class="Wdate" type="text" style="width: 100px" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" />
				</td>
			</tr>
			<tr>
				<td colspan="6" class="bline" align="right">
					<!-- <input type="button" name="btn_submit" value="作废重开"/> -->
				</td></tr>
		</table>
	
		<!-- 列表开始 -->	
		<s:if test="bill.options!=null">
			<br/>
			<table id="tab" width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
			  <tr> 
			    <td width="3%" class="top-td-width-bg"><input type="checkbox" id="check_all" /></td>
			    <td width="4%" class="top-td-width-bg">序号</td>
			    <td width="18%" class="top-td-width-bg">付款方名称</td>
			    <td width="19%" class="top-td-width-bg">应收金额</td>
			    <td width="19%" class="top-td-width-bg">收取月份</td>
			    <td width="18%" class="top-td-width-bg">状态</td>
			    <td width="19%" class="top-td-width-bg">备注</td>
			  </tr>
			 <s:iterator value="bill.options" status="stx" >
				<tr class="data_tr"  height="26" align="center" bgcolor="#FFFFFF" onmousemove="javascript:this.bgColor='#FCFDEE';" onmouseout="javascript:this.bgColor='#FFFFFF';">
					<td  class="down-center-td-width-bg">
						<s:if test="status.index==2">
							<input type="checkbox" name="mid" id="<s:property value="id"/>"/>
						</s:if>
						<s:if test="status.index==7">
							<input type="checkbox" name="mid" id="<s:property value='id'/>"  disabled="disabled" checked="checked" />
						</s:if>
					</td> 
					<td  class="down-center-td-width-bg">
						<s:property value="#stx.index+1"/>
					</td> 
					<td  class="down-center-td-width-bg">
						<s:if test="financial==null">
							<s:property value="shop.shopName"/>
						</s:if>
						<s:else><s:property value="financial.name"/></s:else>
					</td> 
					<td  class="down-center-td-width-bg">
						<s:property value="formatAmount(amount)"/>
					</td> 
					<td  class="down-center-td-width-bg">
						<s:property value="month"/>
					</td> 
					<td  class="down-center-td-width-bg">
						<s:property value="status.name"/>
					</td>
					<td  class="down-center-td-width-bg">
						<s:property value="remark"/>
					</td>
				 	<td style="display: none"><s:property value="id"/></td> 
				</tr>
			</s:iterator>
			</table>
			<table width="100%" border="0" cellpadding="1" cellspacing="1">
			<tr style="padding-top: 20px">
				<td class="bline" colspan="4" align="center">
					<input type="button" name="btn_submit" onclick="build()" id="save" value="作废重开"/>
				</td>
			</tr>
			</table>
		
			<br/>
		</s:if>
		<input type="hidden" name="redirectUrl" value="<s:property value='redirectUrl'/>"/>
		<input type="hidden" name="id" value="<s:property value='bill.id'/>"/>
		<input type="hidden" id="ids" name="ids"/>
		<input type="hidden" id="uncheckIds" name="uncheckIds"/>
		<input type="hidden" id="hasCharged" name="hasCharged"/>
		</form>
		</div>
	</body>
</html>